layui.use(['element', 'layer','form', 'layuimini', 'jquery', 'jquery_cookie'], function () {
    var form = layui.form,
        $ = layui.jquery,
        layer = layui.layer,
        $ = layui.jquery_cookie($);

    form.on('submit(saveBtn)', function (data) {
        var fieldData = data.field;
        //发送ajax修改密码
        $.ajax({
            type: "post",
            url: ctx + "/user/changePwd",
            data: {
                oldPwd: fieldData.old_password,
                newPwd: fieldData.new_password,
                confirmPwd: fieldData.again_password
            },
            dataType: "json",

            success: function (data) {
                if (data.code == 200) {
                    layer.msg("修改成功了", function () {
                        //清空Cookie信息
                        $.removeCookie("userIdStr", {domain: "localhost", path: "/reshare"});
                        $.removeCookie("userName", {domain: "localhost", path: "/reshare"});
                        $.removeCookie("trueName", {domain: "localhost", path: "/reshare"});
                        //跳转
                        window.parent.location.href = ctx + "/index";
                    });
                } else {
                    layer.msg(data.msg);
                }
            }

        });
    });
});